package com.cjzuji.rental.dao.impl;


import com.cjzuji.rental.dao.YpRiskDao;
import com.cjzuji.rental.mapper.YpRiskMapper;
import com.cjzuji.rental.pojo.YpRisk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
@Service
public class YpRiskDaoImpl implements YpRiskDao {

    private static final Logger logger = LoggerFactory.getLogger(YpRiskDaoImpl.class);
    @Autowired
    YpRiskMapper ypRiskMapper;
    @Override
    @Transactional
    public  void save(String orderId, List<String> userInfo){

        YpRisk ypRisk = YpRisk.builder()
                .orderId(orderId)
                .realName(userInfo.get(0))
                .phone(userInfo.get(1))
                .cardId(userInfo.get(4))
                .address(userInfo.get(2))
                .updataTime(new Date())
                .build();
        try {
            ypRiskMapper.insert(ypRisk);
        }catch (Exception e){
            logger.info("订单用户添加错误" + e.getMessage());
            throw e; // 重新抛出，确保事务回滚
        }
    }
}

